cmake_minimum_required(VERSION 3.11)

project(main)

set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED True)

set(PROJ_DIR "/home/cat/camera")
set(RKNN_LIB_DIR "/usr/lib")
set(RKNN_INCLUDE_DIR "/home/cat/rknn-toolkit2-2.3.2/rknpu2/runtime/Linux/librknn_api/include")

find_package(OpenCV REQUIRED)
# 包含头文件路径
include_directories(${OpenCV_INCLUDE_DIRS}
                    ${RKNN_INCLUDE_DIR}
                    ${FFMPEG_INCLUDE_DIRS}
                    "${PROJ_DIR}/include"
                    "${PROJ_DIR}/src"
                    "/usr/include"
                    )
link_directories(${RKNN_LIB_DIR})

add_library(rknn_Detector SHARED src/rknn_Detector.cpp) # 先编译这个库
target_link_libraries(rknn_Detector 
    PRIVATE
    ${OpenCV_LIBS}
    rknn_api
    pthread
    dl
    rt
    )

add_library(Serial SHARED src/serial.cpp)
add_library(kalman_filter SHARED src/kalman_filter.cpp)
add_executable(main main.cpp)

target_link_libraries(  main 
                        ${OpenCV_LIBS} 
                        ${FFMPEG_LIBRARIES}
                        rknn_api
                        pthread
                        dl
                        rt
                        Serial
                        rknn_Detector
                        kalman_filter
                        )

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -Wall")

if(CMAKE_CXX_COMPILER_ID STREQUAL "GNU" AND CMAKE_CXX_COMPILER_VERSION VERSION_LESS 9.0)
    target_link_libraries(digit_template_generator stdc++fs)
endif()
